× Lesson 1 Lesson 2 Lesson 3 Lesson 4 Lesson 5 Lesson 6 Lesson 7 Lesson 8 Lesson 9 Lesson 10 Lesson 11

All lessons

☰ open

Mini Lesson 1: Multiple Variable Names

Welcome to a mini lesson, where I want to introduce a topic, but it is isn't large enough to consider a full lesson. Being able to assign multiple variable names can be useful in many situations. Let me start off with an example, using what we learned from input() and .split(). Say for example that you want to store the first and last name of someone using your program, and you want to be able to store their name as: 'last_name, first_name'. Using multiple variable names, this could be easily done:

first_name, last_name = input().split() print(last_name, first_name)

This would output the aforementioned format, with the last name followed by the first name.